package appfight.map;

import java.util.Random;

import braindamagestudio.com.app.fight.MainGameActivity;

import appfight.icon.manager.IconManager;
import appfight.level.GameLevel;
import appfight.level.GameLevelMap;
import appfight.level.GameLevelMonsterFight;
import appfight.map.GameObjectMap.Map_Object;
import appfight.monster.Monster;

public class CountMonsterObject extends MapObject{

	private GameLevelMap _level;
	private Random random;
	
	public CountMonsterObject(Map_Object objectType,GameLevelMap level) {
		super(objectType);
		_level = level;
		
		random = new Random(System.currentTimeMillis());
	}
	
	@Override
	public void Action()
	{
		int countNum = random.nextInt(10);
		_level._monsterCount += countNum;
		
		if(_level._monsterCount > 100)
		{
		    //Monster Fight Example
			_level._activity.StopAllMusic();
			_level._camera.setChaseEntity(null);
			_level._walkable = false;
		    GameLevel.EndFightActivity = _level.LevelName;
			IconManager m = new IconManager(_level._activity);
			IconManager.IconQueryResult result = m.getAllIconsPath();
			
			int target = (random.nextInt(result.Paths.size()));
			Monster monster = new Monster(result.Names.get(target),result.Paths.get(target));		
			_level._activity.PlayMusic(MainGameActivity.MUSIC_FIGHT, true);
			_level._activity.ChangeLevel(new GameLevelMonsterFight(monster));
			_level._mainCharacter.StopMove();
			MainGameActivity.changedSceneCharacterX = _level._mainCharacter.NowX;
			MainGameActivity.changedSceneCharacterY = _level._mainCharacter.NowY;
			_level._monsterCount = 0;
		}
	}

}
